import request from '@/router/axios';

/**
 * 分页查询
 * @param current
 * @param size
 * @param params
 */
export const getList = (current, size, params) => {
  return request({
    url: '/api/ywsp-management/proCaseInfo/caseInfoBusinessPage',
    method: 'get',
    params: {
      ...params,
      current,
      size,
    }
  })
}
export const getList2 = (current, size, params) => {
  return request({
    url: '/api/ywsp-management/proCaseInfo/caseMateList',
    method: 'get',
    params: {
      ...params,
      current,
      size,
    }
  })
}
/**
 * 查询详情
 * @param id
 */
export const getDetail = (id) => {
  return request({
    url: '/api/ywsp-management/proCaseInfo/caseInfoDetail',
    method: 'get',
    params: {
      id
    }
  })
}
/**
 * 删除
 * @param ids
 */
export const remove = (ids) => {
  return request({
    url: '/api/ywsp-management/activityClockIn/remove',
    method: 'post',
    params: {
      ids,
    }
  })
}
/**
 * 新增
 * @param row
 */
export const add = (row) => {
  return request({
    url: '/api/ywsp-management/activityClockIn/save',
    method: 'post',
    data: row
  })
}
/**
 * 修改
 * @param row
 */
export const update = (row) => {
  return request({
    url: '/api/ywsp-management/activityClockIn/update',
    method: 'post',
    data: row
  })
}

/**
 * 文件流返回
 * @param url 接口地址
 * @param params 接口参数
 */
export const exportBlob = (url, params) => {
  return request({
    url: url,
    params: params,
    method: 'get',
    responseType: 'blob',
  });
};

/**
 * 下载excel
 * @param {blob} fileArrayBuffer 文件流
 * @param {String} filename 文件名称
 */
export const downloadXls = (fileArrayBuffer, filename) => {
  let data = new Blob([fileArrayBuffer], {type: 'application/vnd.ms-excel,charset=utf-8'});
  if (typeof window.chrome !== 'undefined') {
    // Chrome
    var link = document.createElement('a');
    link.href = window.URL.createObjectURL(data);
    link.download = filename;
    link.click();
  } else if (typeof window.navigator.msSaveBlob !== 'undefined') {
    // IE
    var blob = new Blob([data], {type: 'application/force-download'});
    window.navigator.msSaveBlob(blob, filename);
  } else {
    // Firefox
    var file = new File([data], filename, {type: 'application/force-download'});
    window.open(URL.createObjectURL(file));
  }
};

